//
//  OEPresupShopTableViewCell.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/5.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEPresupShopTableViewCell.h"

@interface  OEPresupShopTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;/**<  */

@property(nonatomic, strong) STLabel                     *titleLable;/**<  */
@property(nonatomic, strong) STButton                     *timeButton;/**<  */
@property(nonatomic, strong) STButton                     *addButton;/**<  */
@property(nonatomic, strong) STLabel                     *distenceLable;/**<  */

@end
@implementation OEPresupShopTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 150;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = UIColor.clearColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(20, 0, UIScreenWidth - 40, 140)];
    whiteView.layer.cornerRadius = 10;
    whiteView.clipsToBounds = YES;
    whiteView.backgroundColor = UIColor.whiteColor;
    [self addSubview:whiteView];
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 70, 70)];
    imageView.image = [UIImage imageNamed:@""];
    [whiteView addSubview:imageView];
    imageView.clipsToBounds = YES;
    imageView.layer.cornerRadius = 8;
    self.iconImageView = imageView;
    CGFloat maxWitdh = whiteView.width - imageView.right - 10;
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(imageView.right + 10, imageView.top, maxWitdh, 30)
                                                     text:@""
                                                textColor:FirstTextColor
                                                     font:17
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    [whiteView addSubview:self.titleLable];
    
    self.timeButton = [[STButton alloc] initWithFrame:CGRectMake(self.titleLable.left, self.titleLable.bottom, maxWitdh, 20)
                                                     title:@""
                                                titleColor:SecendTextColor
                                                 titleFont:14
                                              cornerRadius:0
                                           backgroundColor:nil
                                           backgroundImage:nil
                                                     image:[UIImage imageNamed:@"24×24时间"]];
    [whiteView addSubview:self.timeButton];
    
    self.addButton = [[STButton alloc] initWithFrame:CGRectMake(self.titleLable.left, self.timeButton.bottom, maxWitdh - 100, 20)
                                                title:@""
                                           titleColor:SecendTextColor
                                            titleFont:12
                                         cornerRadius:0
                                      backgroundColor:UIColor.whiteColor
                                      backgroundImage:nil
                                                image:[UIImage imageNamed:@"24×30地址"]];
    [whiteView addSubview:self.addButton];
    self.addButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    self.timeButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    
    self.distenceLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)
                                                     text:@""
                                                textColor:SecendTextColor
                                                     font:13
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentRight];
    self.distenceLable.centerY = self.addButton.centerY;
    self.distenceLable.right = whiteView.width - 10;
    [whiteView addSubview:self.distenceLable];
    
    self.appoinmentButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, whiteView.width, 40)
                                                     title:OESTRING(@"APPOINTMENT")
                                                titleColor:OE_LIMITE_COLOR
                                                 titleFont:15
                                              cornerRadius:0
                                           backgroundColor:UIColor.whiteColor
                                           backgroundImage:nil
                                                     image:nil];
    self.appoinmentButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.appoinmentButton st_showTopLine];
    [whiteView addSubview:self.appoinmentButton];
    self.appoinmentButton.bottom = whiteView.height;
}
- (void)setModel:(OEShopEasyModel *)model{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.supplier_logo]];
    self.titleLable.text = model.supplier_name;
    
    [self.timeButton setTitle:[NSString stringWithFormat:@"%@-%@",model.start_time,model.end_time] forState:UIControlStateNormal];
    [self.addButton setTitle:[NSString stringWithFormat:@"%@",model.address] forState:UIControlStateNormal];
    
    self.distenceLable.text = model.distance;
    
}
@end
